<?php foreach($categories as $category): $agency_id = get_root($category->id);?>
<li <?php echo ($category->parent_id == 0)?'class="sub" id="agency-'.$agency_id.'"':'' ?> >
	<?php 
	switch($category->structure->module)
	{
		case 'albums' : echo anchor('albums/admin/albums?agency_id='.$agency_id, lang_decode($category->name)); break;
		case 'calendars' : echo anchor('calendars/admin/calendars?agency_id='.$agency_id, lang_decode($category->name)); break;
		case 'weblinks' : echo anchor('weblinks/admin/weblinks?agency_id='.$agency_id, lang_decode($category->name)); break;
		case 'counters' : echo anchor('counters/admin/counters?agency_id='.$agency_id, lang_decode($category->name)); break;
		case 'webboards' : echo anchor('webboards/admin/webboards?agency_id='.$agency_id, lang_decode($category->name)); break;
		case 'guestbooks' : echo anchor('guestbooks/admin/guestbooks?agency_id='.$agency_id, lang_decode($category->name)); break;
		case 'organizations' : echo anchor('organizations/admin/organizations?agency_id='.$agency_id, lang_decode($category->name)); break;
		case 'boards' : echo anchor('boards/admin/boards?agency_id='.$agency_id, lang_decode($category->name)); break;
		case 'agencies' : echo anchor('agencies/admin/agencies?agency_id='.$agency_id, lang_decode($category->name)); break;
		case 'users' : echo anchor('users/admin/users?agency_id='.$agency_id, lang_decode($category->name)); break;
		case 'polls' : echo anchor('polls/admin/polls?agency_id='.$agency_id, lang_decode($category->name)); break;
		default : echo anchor('contents/admin/contents/index/'.$category->id.'?agency_id='.$agency_id, lang_decode($category->name)); break;
	}
	?>
	<!--
	<a href="contents/admin/contents/index/<?php echo $category->id ?>"><?php echo lang_decode($category->name)?></a>
	-->
	<?php if(($category->parent_id == 0)OR($category->structure->type=='category')): ?>
	<ul class="sub2">
		<?php echo modules::run('contents/admin/categories/menu',$category->id) ?>
		<!--
		<li <?php echo menu_active('calendars','calendars')?>><a href="calendars/admin/calendars">ปฎิทินกิจกรรม</a></li>
		<li <?php echo menu_active('weblinks','weblinks')?>><a href="weblinks/admin/weblinks">เว็บไซค์ที่เกี่ยวข้อง</a></li>
		-->
	</ul>
	<?php endif; ?>
</li>
<?php endforeach; ?>